import request from '@/utils/request'
import {parseStrEmpty} from "@/utils/common";

// 查询用户列表
export function listChannelUser(query) {
  return request({
    url: '/system/channel/agent/list',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getChannelUser(userId) {
  return request({
    url: '/system/channel/agent/' + parseStrEmpty(userId),
    method: 'get'
  })
}

// 新增用户
export function addChannelUser(data) {
  return request({
    url: '/system/channel/agent',
    method: 'post',
    data: data
  })
}

// 启用渠道用户
export function enableChannelUser(userId) {
  return request({
    url: '/system/channel/agent/' + userId + '/status/enable',
    method: 'post'
  })
}

// 禁用渠道用户
export function disabledChannelUser(userId) {
  return request({
    url: '/system/channel/agent/' + userId + '/status/disabled',
    method: 'post'
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/system/channel/agent/changeStatus',
    method: 'put',
    data: data
  })
}

// 重置渠道用户密码
export function resetPasswordChannelUser(data) {
  return request({
    url: '/system/channel/agent/reset/password',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateChannelUser(data) {
  return request({
    url: '/system/channel/agent',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delChannelUser(userId) {
  return request({
    url: '/system/channel/agent/' + userId,
    method: 'delete'
  })
}
